package com.caisejingyu.whales.home.devices.printer;

/**
 * Created by taoisym on 12/2/16.
 */

public enum ShowState {
    SHOWING_AD,
    DEVICE_DISCONNECTED,
    DEVICE_NOINK,
    DEVICE_NOPAPER,
    DEVICE_ERROR,
    SEVICE_DISCONNECTED,
    NETWORK_DISCONNECTED,
    PRINTTING,
    ERR_UNKNOWN,
    NETWORK_ERROR;

    public static ShowState getState(String state) {
        if (SHOWING_AD.name().equals(state)) {
            return SHOWING_AD;
        } else if (DEVICE_DISCONNECTED.name().equals(state)) {
            return DEVICE_DISCONNECTED;
        } else if (DEVICE_NOINK.name().equals(state)) {
            return DEVICE_NOINK;
        } else if (DEVICE_NOPAPER.name().equals(state)) {
            return DEVICE_NOPAPER;
        } else if (DEVICE_ERROR.name().equals(state)) {
            return DEVICE_ERROR;
        } else if (SEVICE_DISCONNECTED.name().equals(state)) {
            return SEVICE_DISCONNECTED;
        } else if (NETWORK_DISCONNECTED.name().equals(state)) {
            return NETWORK_DISCONNECTED;
        } else if (PRINTTING.name().equals(state)) {
            return PRINTTING;
        } else if (ERR_UNKNOWN.name().equals(state)) {
            return ERR_UNKNOWN;
        } else if (NETWORK_ERROR.name().equals(state)) {
            return NETWORK_ERROR;
        } else {
            return SHOWING_AD;
        }
    }

    public static String getErrorMessage(ShowState state) {
        switch (state) {
            case ERR_UNKNOWN:
                return "打印机错误";
            case DEVICE_DISCONNECTED:
                return "打印机未开机";
            case DEVICE_NOPAPER:
                return "打印机没纸了";
            case DEVICE_ERROR:
                return "打印机错误";
            case SEVICE_DISCONNECTED:
                return "服务器未连接";
            case NETWORK_DISCONNECTED:
                return "网络未连接";
            case NETWORK_ERROR:
                return "网络异常";
            default:
                return "暂时无法打印";
        }
    }
}
